/*    */ package com.alipay.util;
/*    */ 
/*    */ import com.alipay.config.AlipayConfig;
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.security.MessageDigest;
/*    */ import java.security.NoSuchAlgorithmException;
/*    */ 
/*    */ public class Md5Encrypt
/*    */ {
/* 22 */   private static final char[] DIGITS = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
/*    */ 
/*    */   public static String md5(String text)
/*    */   {
/* 34 */     MessageDigest msgDigest = null;
/*    */     try
/*    */     {
/* 37 */       msgDigest = MessageDigest.getInstance("MD5");
/*    */     } catch (NoSuchAlgorithmException e) {
/* 39 */       throw new IllegalStateException("System doesn't support MD5 algorithm.");
/*    */     }
/*    */ 
/*    */     try
/*    */     {
/* 44 */       msgDigest.update(text.getBytes(AlipayConfig.input_charset));
/*    */     }
/*    */     catch (UnsupportedEncodingException e)
/*    */     {
/* 48 */       throw new IllegalStateException("System doesn't support your  EncodingException.");
/*    */     }
/*    */ 
/* 53 */     byte[] bytes = msgDigest.digest();
/*    */ 
/* 55 */     String md5Str = new String(encodeHex(bytes));
/*    */ 
/* 57 */     return md5Str;
/*    */   }
/*    */ 
/*    */   public static char[] encodeHex(byte[] data)
/*    */   {
/* 62 */     int l = data.length;
/*    */ 
/* 64 */     char[] out = new char[l << 1];
/*    */ 
/* 67 */     int i = 0; for (int j = 0; i < l; i++) {
/* 68 */       out[(j++)] = DIGITS[((0xF0 & data[i]) >>> 4)];
/* 69 */       out[(j++)] = DIGITS[(0xF & data[i])];
/*    */     }
/*    */ 
/* 72 */     return out;
/*    */   }
/*    */ }

/* Location:           F:\电商\commons-utils.jar
 * Qualified Name:     com.alipay.util.Md5Encrypt
 * JD-Core Version:    0.6.0
 */